package com.yellowpage.wf.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.wf.data.NodeTemplate;
import com.yellowpage.wf.dao.NodeTemplateDao;

public class NodeTemplateServiceImpl extends BaseServiceImpl implements NodeTemplateService {
	  private NodeTemplateDao nodeTemplateDao;
	
	  public void setNodeTemplateDao(NodeTemplateDao nodeTemplateDao) {
		  this.nodeTemplateDao = nodeTemplateDao;
	  }
	
	
	  /* White generate Method */ 
	  public NodeTemplate getNodeTemplate(Long id){
	      return nodeTemplateDao.get(id);
	  }
	  
    public List<NodeTemplate> getAllNodeTemplate(){
        return nodeTemplateDao.getAll();
    }
    
    public List<Map> queryNodeTemplateByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.NODE_TEMPLATE_ID , a.TEMPLATE , a.WORKFLOW_NODE_ID , a.CREATE_USER , a.CREATE_TIME , a.NAME , a.TYPE , a.VERSION , a.DESCRIPTION    FROM WF_NODE_TEMPLATE a WHERE 1=1 ")
				    			.addCondition(" and NODE_TEMPLATE_ID = :nodeTemplateId ")
							    			.addCondition(" and TEMPLATE = :template ")
							    			.addCondition(" and WORKFLOW_NODE_ID = :workflowNodeId ")
							    			.addCondition(" and CREATE_USER = :createUser ")
							    		    .addCondition(" and CREATE_TIME = to_date(:createTime ,'yyyy-MM-dd') ")
		    				    			.addCondition(" and NAME = :name ")
							    			.addCondition(" and TYPE = :type ")
							    			.addCondition(" and VERSION = :version ")
							    			.addCondition(" and DESCRIPTION = :description ")
							    ; 	

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveNodeTemplate(NodeTemplate nodeTemplate){
        nodeTemplateDao.save(nodeTemplate);
    }
    
	  public void updateNodeTemplate(NodeTemplate nodeTemplate){
	      nodeTemplateDao.update(nodeTemplate);
	  }
	  
	  public void delete(List deleteList){
	      nodeTemplateDao.remove(deleteList);
	  }
	  
	  
	 
	
}	